﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;
using DevExpress.Skins;
using DevExpress.Data.Filtering;
using DevExpress.MailClient.Win.Forms;
using System.Drawing;
using DevExpress.MailClient.Win.Data;

namespace DevExpress.MailClient.Win
{


    static class Program
    {

        public static Timer CurrentAppTimer
        { get; set; }

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] arguments)
        {
            DataHelper.ApplicationArguments = arguments;
            DevExpress.Utils.LocalizationHelper.SetCurrentCulture(DataHelper.ApplicationArguments);
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Utils.AppearanceObject.DefaultFont = new Font("Segoe UI", 8);

            string activeSkinName = (!string.IsNullOrEmpty(PRO_DOCS.BLL.WIN.Properties.Settings.Default.ActiveSkinName)) ? PRO_DOCS.BLL.WIN.Properties.Settings.Default.ActiveSkinName : "Office 2013";

            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(activeSkinName);//"Office 2013");

            SkinManager.EnableFormSkins();
            EnumProcessingHelper.RegisterEnum<TaskStatus>();


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            Application.Run(new PRO_DOCS.BLL.WIN.Authentication.SigningIn());

            if (PRO_DOCS.BLL.WIN.Authentication.LOGGED_IN_EMPLOYEE_DETAILS.IS_AUTHENTICATED_USER)
            {
                CurrentAppTimer = new Timer();
                CurrentAppTimer.Interval = 60000;
                CurrentAppTimer.Enabled = true;
                CurrentAppTimer.Tick += new EventHandler(CurrentAppTimer_Tick);
                CurrentAppTimer.Start();
                //----------AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ProCodes.BugTracker.BugCatcher.BugDetails.CurrentDomain_UnhandledException);
                //Application Unhandled Exception catching
                //----------Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(ProCodes.BugTracker.BugCatcher.BugDetails.Application_ThreadException);
                //ReportingService.ApplicationConfigSetting.SetReportingSeriveConfig(PRO_DOCS.ReportingService.ApplicationConfigSetting.MachineType.Offline);
                //new BLL.Database.ApplicationFolders().LoadApplicationFolders(false);

                SplashScreenManager.ShowForm(null, typeof(ssMain), true, true, false, 1000);
                //Application.Run(new PRO_DOCS.DocumentManagementSystem.CLIENT.WIN.Forms.frmDepartmentFilesBulkInsert()); 
                Application.Run(new frmMain());


                PRO_DOCS.BLL.WIN.Authentication.LoggedInEmployeeSession.CLOSE_LOGGED_IN_USER_SESSION();
            }

            PRO_DOCS.BLL.WIN.Properties.Settings.Default.ActiveSkinName = DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveSkinName;
            PRO_DOCS.BLL.WIN.Properties.Settings.Default.Save();
                //;
        }

        static void CurrentAppTimer_Tick(object sender, EventArgs e)
        {
            PRO_DOCS.BLL.WIN.Authentication.LoggedInEmployeeSession.UPDATE_CHECK_IN_LOGGED_IN_USER_SESSION();
        }
    }
}
